package com.csgc.camera.base

import android.os.Bundle
import android.view.LayoutInflater
import androidx.viewbinding.ViewBinding
import com.csgc.camera.widget.dialog.LoadingPop

open class BaseBindingActivity<VB : ViewBinding>(open val block:(LayoutInflater)->VB): BaseActivity() {

    protected val binding by lazy { block(layoutInflater) }

    private val loadingPop:LoadingPop by lazy {
        LoadingPop(this,true)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)
    }

    /**
     * 显示加载对话框
     * @param message 自定义文字提示
     */
    protected fun showLoading() {
        // 如果加载视图不存在，则创建它

        if (loadingPop != null) {
            loadingPop.showLoading( false)
        }

    }

    /**
     * 隐藏加载对话框
     */
    protected fun hideLoading() {
        if (loadingPop != null) {
            loadingPop.dismissLoading()
        }
    }
}